﻿using System;
using System.Data;
using CardLogistics.Web.Components;

namespace CardLogistics.Web.MainPage.SystemMgr.SysRole
{
    public partial class ListInfo : BasePage
    {
        private static readonly CardLogistics.DAL.Sys.Sys_SysRolesData DAL = new DAL.Sys.Sys_SysRolesData();
        protected void Page_Load(object sender, EventArgs e)
        {
            WebUserControl_ToolBar1.DeleteEvent += new EventHandler(WebUserControl_ToolBar1_DeleteEvent);
            if (!IsPostBack)
            {
                BindRpt(0);
            }
        }

        /// <summary>
        /// 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void WebUserControl_ToolBar1_DeleteEvent(object sender, EventArgs e)
        {
            string delId = this.hdf_Id.Value;

            string resStr = DAL.Delete(delId);
            if (resStr.Split(',')[0] == "ok")
            {
                BindRpt(0);
                InsertLog("删除角色信息");
            }
            else
            {
                ShowMessageBox("删除失败," + resStr.Split(',')[1]);
            }

        }

        /// <summary>
        /// 绑定Rpt数据
        /// </summary>
        /// <param name="pageIndex"></param>
        private void BindRpt(int pageIndex)
        {
            int recordCount = 0;
            int pageCount = 0;
            DataTable dt = CardLogistics.DAL.CommonData.QuickPage_Oracle("SYS_SYSROLES", "ID", " SORTCODE,CREATEDATE ", AspNetPager1.PageSize, pageIndex, "DELETEMARK=1 and ENABLED=0", "*", out pageCount, out recordCount);
            SetNetPagerHtml(AspNetPager1, dt, rptList, recordCount);
        }


        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            WebPageIndex = AspNetPager1.CurrentPageIndex;
            BindRpt(AspNetPager1.CurrentPageIndex);
        }
    }
}